Instruction and logic for processing text strings

ABSTRACT

A processor includes a decoder logic to decode a compare instruction, and an execution unit to execute the compare instruction. The compare instruction is to cause the processor to compare integer data elements of a first 64-bit SIMD integer operand with integer data elements of a second 64-bit SIMD integer operand. The integer data elements of the first 64-bit SIMD integer operand to be compared with the integer data elements of the second 64-bit SIMD integer operand are to be in same data element positions. The compare instruction is also to cause the processor to store a plurality of indicators of whether the compared integer data elements of the first and second 64-bit SIMD integer operands are equal. The plurality of indicators are expanded data elements, each of a first multi-bit size.

This is a Continuation of application Ser. No. 13/843,576, filed Mar.15, 2013, currently pending, which is a Continuation of application Ser.No. 13/164,715, filed Jun. 20, 2011, currently pending, which is aContinuation of application Ser. No. 11/525,981, filed Sep. 22, 2006,currently pending.

FIELD OF THE DISCLOSURE

The present disclosure pertains to the field of processing apparatusesand associated software and software sequences that perform logical andmathematical operations.

BACKGROUND OF THE DISCLOSURE

Computer systems have become increasingly pervasive in our society. Theprocessing capabilities of computers have increased the efficiency andproductivity of workers in a wide spectrum of professions. As the costsof purchasing and owning a computer continues to drop, more and moreconsumers have been able to take advantage of newer and faster machines.Furthermore, many people enjoy the use of notebook computers because ofthe freedom. Mobile computers allow users to easily transport their dataand work with them as they leave the office or travel. This scenario isquite familiar with marketing staff, corporate executives, and evenstudents.

As processor technology advances, newer software code is also beinggenerated to run on machines with these processors. Users generallyexpect and demand higher performance from their computers regardless ofthe type of software being used. One such issue can arise from the kindsof instructions and operations that are actually being performed withinthe processor. Certain types of operations require more time to completebased on the complexity of the operations and/or type of circuitryneeded. This provides an opportunity to optimize the way certain complexoperations are executed inside the processor.

Communications applications have been driving microprocessor developmentfor more than a decade. In fact, the line between computing andcommunication has become increasingly blurred due, in part, to the useof textual communication applications. Textual applications arepervasive within consumer segments, and among numerous devices, fromcell phones to personal computers, requiring faster and fasterprocessing of text information. Textual communication devices continueto find their way into computing and communication devices in the formof applications, such as Microsoft® Instant Messenger™, emailapplications, such as Microsoft® Outlook™, and cell phone textingapplications. As a result, tomorrow's personal computing andcommunications experience will be even richer in textual capability.

Accordingly, the processing or parsing of text information communicatedbetween computing or communication devices has become increasinglyimportant for current computing and communication devices. Particularly,interpretation by a communication or computing device of strings of textinformation include some of the most important operations performed ontext data. Such operations may be computationally intensive, but offer ahigh level of data parallelism that can be exploited through anefficient implementation using various data storage devices, such as forexample, single instruction multiple data (SIMD) registers. A number ofcurrent architectures also require multiple operations, instructions, orsub-instructions (often referred to as “micro-operations” or “uops”) toperform various logical and mathematical operations on a number ofoperands, thereby diminishing throughput and increasing the number ofclock cycles required to perform the logical and mathematicaloperations.

For example, an instruction sequence consisting of a number ofinstructions may be required to perform one or more operations necessaryto interpret particular words of a text string, including comparing twoor more text words represented by various datatypes within a processingapparatus, system or computer program. However, such prior arttechniques may require numerous processing cycles and may cause aprocessor or system to consume unnecessary power in order to generatethe result. Furthermore, some prior art techniques may be limited in theoperand datatypes that may be operated upon.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention is illustrated by way of example and notlimitation in the Figures of the accompanying drawings:

FIG. 1A is a block diagram of a computer system formed with a processorthat includes execution units to execute an instruction for stringcomparison operations in accordance with one embodiment of the presentinvention;

FIG. 1B is a block diagram of another exemplary computer system inaccordance with an alternative embodiment of the present invention;

FIG. 1C is a block diagram of yet another exemplary computer system inaccordance with another alternative embodiment of the present invention;

FIG. 2 is a block diagram of the micro-architecture for a processor ofone embodiment that includes logic circuits to perform one or morestring comparison operations in accordance with the present invention;

FIG. 3A illustrates various packed data type representations inmultimedia registers according to one embodiment of the presentinvention;

FIG. 3B illustrates packed data-types in accordance with an alternativeembodiment;

FIG. 3C illustrates various signed and unsigned packed data typerepresentations in multimedia registers according to one embodiment ofthe present invention;

FIG. 3D illustrates one embodiment of an operation encoding (opcode)form at;

FIG. 3E illustrates an alternative operation encoding (opcode) format;

FIG. 3F illustrates yet another alternative operation encoding format;

FIG. 4 is a block diagram of a logic to perform at least one stringcomparison operation on one or more single precision packed dataoperands in accordance with one embodiment of the present invention;

FIG. 5 is a block diagram of arrays that may be used to perform at leastone string comparison operation according to one embodiment.

FIG. 6 illustrates operations that may be performed in one embodiment ofthe invention.

DETAILED DESCRIPTION

The following description describes embodiments of a technique toperform a comparison operation between text or string elements within aprocessing apparatus, computer system, or software program. In thefollowing description, numerous specific details such as processortypes, micro-architectural conditions, events, enablement mechanisms,and the like are set forth in order to provide a more thoroughunderstanding of the present invention. It will be appreciated, however,by one skilled in the art that the invention may be practiced withoutsuch specific details. Additionally, some well known structures,circuits, and the like have not been shown in detail to avoidunnecessarily obscuring the present invention.

Although the following embodiments are described with reference to aprocessor, other embodiments are applicable to other types of integratedcircuits and logic devices. The same techniques and teachings of thepresent invention can easily be applied to other types of circuits orsemiconductor devices that can benefit from higher pipeline throughputand improved performance. The teachings of the present invention areapplicable to any processor or machine that performs data manipulations.However, the present invention is not limited to processors or machinesthat perform 256 bit, 128 bit, 64 bit, 32 bit, or 16 bit data operationsand can be applied to any processor and machine in which manipulation ofpacked data is needed.

In the following description, for purposes of explanation, numerousspecific details are set forth in order to provide a thoroughunderstanding of the present invention. One of ordinary skill in theart, however, will appreciate that these specific details are notnecessary in order to practice the present invention. In otherinstances, well known electrical structures and circuits have not beenset forth in particular detail in order to not necessarily obscure thepresent invention. In addition, the following description providesexamples, and the accompanying drawings show various examples for thepurposes of illustration. However, these examples should not beconstrued in a limiting sense as they are merely intended to provideexamples of the present invention rather than to provide an exhaustivelist of all possible implementations of the present invention.

Although the below examples describe instruction handling anddistribution in the context of execution units and logic circuits, otherembodiments of the present invention can be accomplished by way ofsoftware. In one embodiment, the methods of the present invention areembodied in machine-executable instructions. The instructions can beused to cause a general-purpose or special-purpose processor that isprogrammed with the instructions to perform the steps of the presentinvention. The present invention may be provided as a computer programproduct or software which may include a machine or computer-readablemedium having stored thereon instructions which may be used to program acomputer (or other electronic devices) to perform a process according tothe present invention. Alternatively, the steps of the present inventionmight be performed by specific hardware components that containhardwired logic for performing the steps, or by any combination ofprogrammed computer components and custom hardware components. Suchsoftware can be stored within a memory in the system. Similarly, thecode can be distributed via a network or by way of other computerreadable media.

Thus a machine-readable medium may include any mechanism for storing ortransmitting information in a form readable by a machine (e.g., acomputer), but is not limited to, floppy diskettes, optical disks,Compact Disc, Read-Only Memory (CD-ROMs), and magneto-optical disks,Read-Only Memory (ROMs), Random Access Memory (RAM), ErasableProgrammable Read-Only Memory (EPROM), Electrically ErasableProgrammable Read-Only Memory (EEPROM), magnetic or optical cards, flashmemory, a transmission over the Internet, electrical, optical,acoustical or other forms of propagated signals (e.g., carrier waves,infrared signals, digital signals, etc.) or the like. Accordingly, thecomputer-readable medium includes any type of media/machine-readablemedium suitable for storing or transmitting electronic instructions orinformation in a form readable by a machine (e.g., a computer).Moreover, the present invention may also be downloaded as a computerprogram product. As such, the program may be transferred from a remotecomputer (e.g., a server) to a requesting computer (e.g., a client). Thetransfer of the program may be by way of electrical, optical,acoustical, or other forms of data signals embodied in a carrier wave orother propagation medium via a communication link (e.g., a modem,network connection or the like).

A design may go through various stages, from creation to simulation tofabrication. Data representing a design may represent the design in anumber of manners. First, as is useful in simulations, the hardware maybe represented using a hardware description language or anotherfunctional description language Additionally, a circuit level model withlogic and/or transistor gates may be produced at some stages of thedesign process. Furthermore, most designs, at some stage, reach a levelof data representing the physical placement of various devices in thehardware model. In the case where conventional semiconductor fabricationtechniques are used, the data representing the hardware model may be thedata specifying the presence or absence of various features on differentmask layers for masks used to produce the integrated circuit. In anyrepresentation of the design, the data may be stored in any form of amachine readable medium. An optical or electrical wave modulated orotherwise generated to transmit such information, a memory, or amagnetic or optical storage such as a disc may be the machine readablemedium. Any of these mediums may “carry” or “indicate” the design orsoftware information. When an electrical carrier wave indicating orcarrying the code or design is transmitted, to the extent that copying,buffering, or re-transmission of the electrical signal is performed, anew copy is made. Thus, a communication provider or a network providermay make copies of an article (a carrier wave) embodying techniques ofthe present invention.

In modem processors, a number of different execution units are used toprocess and execute a variety of code and instructions. Not allinstructions are created equal as some are quicker to complete whileothers can take an enormous number of clock cycles. The faster thethroughput of instructions, the better the overall performance of theprocessor. Thus it would be advantageous to have as many instructionsexecute as fast as possible. However, there are certain instructionsthat have greater complexity and require more in terms of execution timeand processor resources. For example, there are floating pointinstructions, load/store operations, data moves, etc.

As more and more computer systems are used in internet, text, andmultimedia applications, additional processor support has beenintroduced over time. For instance, Single Instruction, Multiple Data(SIMD) integer/floating point instructions and Streaming SIME Extensions(SSE) are instructions that reduce the overall number of instructionsrequired to execute a particular program task, which in turn can reducethe power consumption. These instructions can speed up softwareperformance by operating on multiple data elements in parallel. As aresult, performance gains can be achieved in a wide range ofapplications including video, speech, and image/photo processing. Theimplementation of SIMD instructions in microprocessors and similar typesof logic circuit usually involve a number of issues. Furthermore, thecomplexity of SIMD operations often leads to a need for additionalcircuitry in order to correctly process and manipulate the data.

Presently a SIMD instruction that compares each data element of at leasttwo packed operands is not available. Without the presence of a SIMDpacked comparison instruction, such as that performed by one embodiment,a large number of instructions and data registers may be needed toaccomplish the same results in applications such as text interpretation,compression/de-compression, processing, and manipulation. Embodimentsdisclosed herein make reference to text or string comparisonsinterchangeably. However, embodiments may be applied to any string ofinformation (text, numbers, or other data).

Thus, at least one string compare instruction in accordance withembodiments of the present invention can reduce code overhead andresource requirements. Embodiments of the present invention provide away to implement a text parsing operation as an algorithm that makes useof SIMD related hardware. Presently, it is somewhat difficult andtedious to perform text parsing operations on data in a SIMD register.Some algorithms require more instructions to arrange data for arithmeticoperations than the actual number of instructions to execute thoseoperations. By implementing embodiments of text comparison operations inaccordance with embodiments of the present invention, the number ofinstructions needed to achieve text processing can be drasticallyreduced.

Embodiments of the present invention involve an instruction forimplementing one or more string comparison operations. A text comparisonoperation generally involves comparing data elements from two strings ofdata to determine which data elements match. Other variations may bemade on the generic text comparison algorithm, which will be discussedherein. In a generalized sense, one embodiment of a text comparisonoperation as applied to individual data elements in two packed operandsrepresenting two strings of data can be generically represented as:

DEST1←SRC1 cmp SRC2;

For a packed SIMD data operand, this generic operation can be applied toeach data element position of each operand.

In the above operation, “DEST” and “SRC” are generic terms to representthe destination and source of the corresponding data or operation. Insome embodiments, they may be implemented by registers, memory, or otherstorage areas having other names or functions than those depicted. Forexample, in one embodiment, DEST1 may be a temporary storage register orother storage area, whereas SRC1 and SRC2 may be a first and secondsource storage register or other storage area, and so forth. In otherembodiments, two or more of the SRC and DEST storage areas maycorrespond to different data storage elements within the same storagearea (e.g., a SIMD register).

Furthermore, in one embodiment, a string comparison operation maygenerate an indicator of whether each element of one of the sourceregisters is equal to each element of the other source register andstore the indicator into a register, such as DEST1. In one embodiment,the indicator is an index value, whereas in other embodiments theindicator may be a mask value. In other embodiments, the indicator mayrepresent other data structures or pointers.

FIG. 1A is a block diagram of an exemplary computer system formed with aprocessor that includes execution units to execute an instruction for astring comparison operation in accordance with one embodiment of thepresent invention. System 100 includes a component, such as a processor102 to employ execution units including logic to perform algorithms forprocess data, in accordance with the present invention, such as in theembodiment described herein. System 100 is representative of processingsystems based on the PENTIUM® III, PENTIUM® 4, Xeon™, Itanium®, XScale™and/or StrongARM™ microprocessors available from Intel Corporation ofSanta Clara, Calif., although other systems (including PCs having othermicroprocessors, engineering workstations, set-top boxes and the like)may also be used. In one embodiment, sample system 100 may execute aversion of the WINDOWS™ operating system available from MicrosoftCorporation of Redmond, Wash., although other operating systems (UNIXand Linux for example), embedded software, and/or graphical userinterfaces, may also be used. Thus, embodiments of the present inventionis not limited to any specific combination of hardware circuitry andsoftware.

Embodiments are not limited to computer systems. Alternative embodimentsof the present invention can be used in other devices such as handhelddevices and embedded applications. Some examples of handheld devicesinclude cellular phones, Internet Protocol devices, digital cameras,personal digital assistants (PDAs), and handheld PCs. Embeddedapplications can include a micro controller, a digital signal processor(DSP), system on a chip, network computers (NetPC), set-top boxes,network hubs, wide area network (WAN) switches, or any other system thatperforms string comparison operations on operands. Furthermore, somearchitectures have been-implemented to enable instructions to operate onseveral data simultaneously to improve the efficiency of multimediaapplications. As the type and volume of data increases, computers andtheir processors have to be enhanced to manipulate data in moreefficient methods.

FIG. 1A is a block diagram of a computer system 100 formed with aprocessor 102 that includes one or more execution units 108 to performan algorithm to compare data elements from one or more operands inaccordance with one embodiment of the present invention. One embodimentmay be described in the context of a single processor desktop or serversystem, but alternative embodiments can be included in a multiprocessorsystem. System 100 is an example of a hub architecture. The computersystem 100 includes a processor 102 to process data signals. Theprocessor 102 can be a complex instruction set computer (CISC)microprocessor, a reduced instruction set computing (RISC)microprocessor, a very long instruction word (VLIW) microprocessor, aprocessor implementing a combination of instruction sets, or any otherprocessor device, such as a digital signal processor, for example. Theprocessor 102 is coupled to a processor bus 110 that can transmit datasignals between the processor 102 and other components in the system100. The elements of system 100 perform their conventional functionsthat are well known to those familiar with the art.

In one embodiment, the processor 102 includes a Level 1 (L1) internalcache memory 104. Depending on the architecture, the processor 102 canhave a single internal cache or multiple levels of internal cache.Alternatively, in another embodiment, the cache memory can resideexternal to the processor 102. Other embodiments can also include acombination of both internal and external caches depending on theparticular implementation and needs. Register file 106 can storedifferent types of data in various registers including integerregisters, floating point registers, status registers, and instructionpointer register.

Execution unit 108, including logic to perform integer and floatingpoint operations, also resides in the processor 102. The processor 102also includes a microcode (ucode) ROM that stores microcode for certainmacroinstructions. For this embodiment, execution unit 108 includeslogic to handle a packed instruction set 109. In one embodiment, thepacked instruction set 109 includes a packed string comparisoninstruction for comparing elements of a number of operands. By includingthe packed instruction set 109 in the instruction set of ageneral-purpose processor 102, along with associated circuitry toexecute the instructions, the operations used by many multimediaapplications may be performed using packed data in a general-purposeprocessor 102. Thus, many multimedia applications can be accelerated andexecuted more efficiently by using the full width of a processor's databus for performing operations on packed data. This can eliminate theneed to transfer smaller units of data across the processor's data busto perform one or more operations one data element at a time.

Alternate embodiments of an execution unit 108 can also be used in microcontrollers, embedded processors, graphics devices, DSPs, and othertypes of logic circuits. System 100 includes a memory 120. Memory 120can be a dynamic random access memory (DRAM) device, a static randomaccess memory (SRAM) device, flash memory device, or other memorydevice. Memory 120 can store instructions and/or data represented bydata signals that can be executed by the processor 102.

A system logic chip 116 is coupled to the processor bus 110 and memory120. The system logic chip 116 in the illustrated embodiment is a memorycontroller hub (MCH). The processor 102 can communicate to the MCH 116via a processor bus 110. The MCH 116 provides a high bandwidth memorypath 118 to memory 120 for instruction and data storage and for storageof graphics commands, data and textures. The MCH 116 is to direct datasignals between the processor 102, memory 120, and other components inthe system 100 and to bridge the data signals between processor bus 110,memory 120, and system I/O 122. In some embodiments, the system logicchip 116 can provide a graphics port for coupling to a graphicscontroller 112. The MCH 116 is coupled to memory 120 through a memoryinterface 118. The graphics card 112 is coupled to the MCH 116 throughan Accelerated Graphics Port (AGP) interconnect 114.

System 100 uses a proprietary hub interface bus 122 to couple the MCH116 to the I/O controller hub (ICH) 130. The ICH 130 provides directconnections to some I/O devices via a local I/O bus. The local I/O busis a high-speed I/O bus for connecting peripherals to the memory 120,chipset, and processor 102. Some examples are the audio controller,firmware hub (flash BIOS) 128, wireless transceiver 126, data storage124, legacy I/O controller containing user input and keyboardinterfaces, a serial expansion port such as Universal Serial Bus (USB),and a network controller 134. The data storage device 124 can comprise ahard disk drive, a floppy disk drive, a CD-ROM device, a flash memorydevice, or other mass storage device.

For another embodiment of a system, an execution unit to execute analgorithm with a string comparison instruction can be used with a systemon a chip. One embodiment of a system on a chip comprises of a processorand a memory. The memory for one such system is a flash memory. Theflash memory can be located on the same die as the processor and othersystem components. Additionally, other logic blocks such as a memorycontroller or graphics controller can also be located on a system on achip.

FIG. 1B illustrates a data processing system 140 which implements theprinciples of one embodiment of the present invention. It will bereadily appreciated by one of skill in the art that the embodimentsdescribed herein can be used with alternative processing systems withoutdeparture from the scope of the invention.

Computer system 140 comprises a processing core 159 capable ofperforming SIMD operations including a string comparison operation. Forone embodiment, processing core 159 represents a processing unit of anytype of architecture, including but not limited to a CISC, a RISC or aVLIW type architecture. Processing core 159 may also be suitable formanufacture in one or more process technologies and by being representedon a machine readable media in sufficient detail, may be suitable tofacilitate said manufacture.

Processing core 159 comprises an execution unit 142, a set of registerfile(s) 145, and a decoder 144. Processing core 159 also includesadditional circuitry (not shown) which is not necessary to theunderstanding of the present invention. Execution unit 142 is used forexecuting instructions received by processing core 159. In addition torecognizing typical processor instructions, execution unit 142 canrecognize instructions in packed instruction set 143 for performingoperations on packed data formats. Packed instruction set 143 includesinstructions for supporting string comparison operations, and may alsoinclude other packed instructions. Execution unit 142 is coupled toregister file 145 by an internal bus. Register file 145 represents astorage area on processing core 159 for storing information, includingdata. As previously mentioned, it is understood that the storage areaused for storing the packed data is not critical. Execution unit 142 iscoupled to decoder 144. Decoder 144 is used for decoding instructionsreceived by processing core 159 into control signals and/or microcodeentry points. In response to these control signals and/or microcodeentry points, execution unit 142 performs the appropriate operations.

Processing core 159 is coupled with bus 141 for communicating withvarious other system devices, which may include but are not limited to,for example, synchronous dynamic random access memory (SDRAM) control146, static random access memory (SRAM) control 147, burst flash memoryinterface 148, personal computer memory card international association(PCMCIA)/compact flash (CF) card control 149, liquid crystal display(LCD) control 150, direct memory access (DMA) controller 151, andalternative bus master interface 152. In one embodiment, data processingsystem 140 may also comprise an I/O bridge 154 for communicating withvarious I/O devices via an I/O bus 153. Such I/O devices may include butare not limited to, for example, universal asynchronousreceiver/transmitter (UART) 155, universal serial bus (USB) 156,Bluetooth wireless UART 157 and I/O expansion interface 158.

One embodiment of data processing system 140 provides for mobile,network and/or wireless communications and a processing core 159 capableof performing SIMD operations including a string comparison operation.Processing core 159 may be programmed with various audio, video, imagingand communications algorithms including discrete transformations such asa Walsh-Hadamard transform, a fast Fourier transform (FFT), a discretecosine transform (DCT), and their respective inverse transforms;compression/decompression techniques such as color space transformation,video encode motion estimation or video decode motion compensation; andmodulation/demodulation (MODEM) functions such as pulse coded modulation(PCM).

FIG. 1C illustrates yet another alternative embodiments of a dataprocessing system capable of performing SIMD string comparisonoperations. In accordance with one alternative embodiment, dataprocessing system 160 may include a main processor 166, a SIMDcoprocessor 161, a cache memory 167, and an input/output system 168. Theinput/output system 168 may optionally be coupled to a wirelessinterface 169. SIMD coprocessor 161 is capable of performing SIMDoperations including string comparison operations. Processing core 170may be suitable for manufacture in one or more process technologies andby being represented on a machine readable media in sufficient detail,may be suitable to facilitate the manufacture of all or part of dataprocessing system 160 including processing core 170.

For one embodiment, SIMD coprocessor 161 comprises an execution unit 162and a set of register file(s) 164. One embodiment of main processor 165comprises a decoder 165 to recognize instructions of instruction set 163including SIMD string comparison instructions for execution by executionunit 162. For alternative embodiments, SIMD coprocessor 161 alsocomprises at least part of decoder 165B to decode instructions ofinstruction set 163. Processing core 170 also includes additionalcircuitry (not shown) which is not necessary to the understanding ofembodiments of the present invention.

In operation, the main processor 166 executes a stream of dataprocessing instructions that control data processing operations of ageneral type including interactions with the cache memory 167, and theinput/output system 168. Embedded within the stream of data processinginstructions are SIMD coprocessor instructions. The decoder 165 of mainprocessor 166 recognizes these SIMD coprocessor instructions as being ofa type that should be executed by an attached SIMD coprocessor 161.Accordingly, the main processor 166 issues these SIMD coprocessorinstructions (or control signals representing SIMD coprocessorinstructions) on the coprocessor bus 166 where from they are received byany attached SIMD coprocessors. In this case, the SIMD coprocessor 161will accept and execute any received SIMD coprocessor instructionsintended for it.

Data may be received via wireless interface 169 for processing by theSIMD coprocessor instructions. For one example, voice communication maybe received in the form of a digital signal, which may be processed bythe SIMD coprocessor instructions to regenerate digital audio samplesrepresentative of the voice communications. For another example,compressed audio and/or video may be received in the form of a digitalbit stream, which may be processed by the SIMD coprocessor instructionsto regenerate digital audio samples and/or motion video frames. For oneembodiment of processing core 170, main processor 166, and a SIMDcoprocessor 161 are integrated into a single processing core 170comprising an execution unit 162, a set of register file(s) 164, and adecoder 165 to recognize instructions of instruction set 163 includingSIMD string comparison instructions.

FIG. 2 is a block diagram of the micro-architecture for a processor 200that includes logic circuits to perform a string comparison instructionin accordance with one embodiment of the present invention. For oneembodiment of the string comparison instruction, the instruction cancompare each data element of a first operand with each data element of asecond operand and store an indicator of whether there is a match foreach comparison. In some embodiments, the string comparison instructioncan be implemented to operate on data elements having sizes of byte,word, doubleword, quadword, etc., and datatypes, such as integer andfloating point datatypes In one embodiment the in-order front end 201 isthe part of the processor 200 that fetches macro-instructions to beexecuted and prepares them to be used later in the processor pipeline.The front end 201 may include several units. In one embodiment, theinstruction prefetcher 226 fetches macro-instructions from memory andfeeds them to an instruction decoder 228 which in turn decodes them intoprimitives called micro-instructions or micro-operations (also calledmicro op or uops) that the machine can execute. In one embodiment, thetrace cache 230 takes decoded uops and assembles them into programordered sequences or traces in the uop queue 234 for execution. When thetrace cache 230 encounters a complex macro-instruction, the microcodeROM 232 provides the uops needed to complete the operation.

Many macro-instructions are converted into a single micro-op, whereasothers need several micro-ops to complete the full operation. In oneembodiment, if more than four micro-ops are needed to complete amacro-instruction, the decoder 228 accesses the microcode ROM 232 to dothe macro-instruction. For one embodiment, a packed string comparisoninstruction can be decoded into a small number of micro ops forprocessing at the instruction decoder 228. In another embodiment, aninstruction for a packed string comparison algorithm can be storedwithin the microcode ROM 232 should a number of micro-ops be needed toaccomplish the operation. The trace cache 230 refers to a entry pointprogrammable logic array (PLA) to determine a correct micro-instructionpointer for reading the micro-code sequences for the string comparisonalgorithm in the micro-code ROM 232. After the microcode ROM 232finishes sequencing micro-ops for the current macro-instruction, thefront end 201 of the machine resumes fetching micro-ops from the tracecache 230.

Some SIMD and other multimedia types of instructions are consideredcomplex instructions. Most floating point related instructions are alsocomplex instructions. As such, when the instruction decoder 228encounters a complex macro-instruction, the microcode ROM 232 isaccessed at the appropriate location to retrieve the microcode sequencefor that macro-instruction. The various micro-ops needed for performingthat macro-instruction are communicated to the out-of-order executionengine 203 for execution at the appropriate integer and floating pointexecution units.

The out-of-order execution engine 203 is where the micro-instructionsare prepared for execution. The out-of-order execution logic has anumber of buffers to smooth out and re-order the flow ofmicro-instructions to optimize performance as they go down the pipelineand get scheduled for execution. The allocator logic allocates themachine buffers and resources that each uop needs in order to execute.The register renaming logic renames logic registers onto entries in aregister file. The allocator also allocates an entry for each uop in oneof the two uop queues, one for memory operations and one for non-memoryoperations, in front of the instruction schedulers: memory scheduler,fast scheduler 202, slow/general floating point scheduler 204, andsimple floating point scheduler 206. The uop schedulers 202, 204, 206,determine when a uop is ready to execute based on the readiness of theirdependent input register operand sources and the availability of theexecution resources the uops need to complete their operation. The fastscheduler 202 of this embodiment can schedule on each half of the mainclock cycle while the other schedulers can only schedule once per mainprocessor clock cycle. The schedulers arbitrate for the dispatch portsto schedule uops for execution.

Register files 208, 210, sit between the schedulers 202, 204, 206, andthe execution units 212, 214, 216, 218, 220, 222, 224 in the executionblock 211. There is a separate register file 208, 210, for integer andfloating point operations, respectively. In other embodiments, theinteger and floating point registers may be located in the same registerfile. Each register file 208, 210, of this embodiment also includes abypass network that can bypass or forward just completed results thathave not yet been written into the register file to new dependent uops.The integer register file 208 and the floating point register file 210are also capable of communicating data with the other. For oneembodiment, the integer register file 208 is split into two separateregister files, one register file for the low order 32 bits of data anda second register file for the high order 32 bits of data. The floatingpoint register file 210 of one embodiment has 128 bit wide entriesbecause floating point instructions typically have operands from 64 to128 bits in width.

The execution block 211 contains the execution units 212, 214, 216, 218,220, 222, 224, where the instructions are actually executed. Thissection includes the register files 208, 210, that store the integer andfloating point data operand values that the micro-instructions need toexecute. The processor 200 of this embodiment is comprised of a numberof execution units: address generation unit (AGU) 212, AGU 214, fast ALU216, fast ALU 218, slow ALU 220, floating point ALU 222, floating pointmove unit 224. For this embodiment, the floating point execution blocks222, 224, execute floating point, MMX, SIMD, and SSE operations. Thefloating point ALU 222 of this embodiment includes a 64 bit by 64 bitfloating point divider to execute divide, square root, and remaindermicro-ops. For embodiments of the present invention, any act involving afloating point value occurs with the floating point hardware. Forexample, conversions between integer format and floating point formatinvolve a floating point register file. Similarly, a floating pointdivide operation happens at a floating point divider. On the other hand,non-floating point numbers and integer type are handled with integerhardware resources. The simple, very frequent ALU operations go to thehigh-speed ALU execution units 216, 218. The fast ALUs 216, 218, of thisembodiment can execute fast operations with an effective latency of halfa clock cycle. For one embodiment, most complex integer operations go tothe slow ALU 220 as the slow ALU 220 includes integer execution hardwarefor long latency type of operations, such as a multiplier, shifts, flaglogic, and branch processing. Memory load/store operations are executedby the AGUs 212, 214. For this embodiment, the integer ALUs 216, 218,220, are described in the context of performing integer operations on 64bit data operands. In alternative embodiments, the ALUs 216, 218, 220,can be implemented to support a variety of data bits including 16, 32,128, 256, etc. Similarly, the floating point units 222, 224, can beimplemented to support a range of operands having bits of variouswidths. For one embodiment, the floating point units 222, 224, canoperate on 128 bits wide packed data operands in conjunction with SIMDand multimedia instructions.

In this embodiment, the uops schedulers 202, 204, 206, dispatchdependent operations before the parent load has finished executing. Asuops are speculatively scheduled and executed in processor 200, theprocessor 200 also includes logic to handle memory misses. If a dataload misses in the data cache, there can be dependent operations inflight in the pipeline that have left the scheduler with temporarilyincorrect data. A replay mechanism tracks and re-executes instructionsthat use incorrect data. Only the dependent operations need to bereplayed and the independent ones are allowed to complete. Theschedulers and replay mechanism of one embodiment of a processor arealso designed to catch instruction sequences for string comparisonoperations.

The term “registers” is used herein to refer to the on-board processorstorage locations that are used as part of macro-instructions toidentify operands. In other words, the registers referred to herein arethose that are visible from the outside of the processor (from aprogrammer's perspective). However, the registers of an embodimentshould not be limited in meaning to a particular type of circuit.Rather, a register of an embodiment need only be capable of storing andproviding data, and performing the functions described herein. Theregisters described herein can be implemented by circuitry within aprocessor using any number of different techniques, such as dedicatedphysical registers, dynamically allocated physical registers usingregister renaming, combinations of dedicated and dynamically allocatedphysical registers, etc. In one embodiment, integer registers storethirty-two bit integer data. A register file of one embodiment alsocontains eight multimedia SIMD registers for packed data. For thediscussions below, the registers are understood to be data registersdesigned to hold packed data, such as 64 bits wide MMX™ registers (alsoreferred to as ‘mm’ registers in some instances) in microprocessorsenabled with MMX technology from Intel Corporation of Santa Clara,Calif. These MMX registers, available in both integer and floating pointforms, can operated with packed data elements that accompany SIMD andSSE instructions. Similarly, 128 bits wide XMM registers relating toSSE2, SSE3, SSE4, or beyond (referred to generically as “SSEx”)technology can also be used to hold such packed data operands. In thisembodiment, in storing packed data and integer data, the registers donot need to differentiate between the two data types.

In the examples of the following figures, a number of data operands aredescribed. FIG. 3A illustrates various packed data type representationsin multimedia registers according to one embodiment of the presentinvention. FIG. 3A illustrates data types for a packed byte 310, apacked word 320, and a packed doubleword (dword) 330 for 128 bits wideoperands. The packed byte format 310 of this example is 128 bits longand contains sixteen packed byte data elements. A byte is defined hereas 8 bits of data. Information for each byte data element is stored inbit 7 through bit 0 for byte 0, bit 15 through bit 8 for byte 1, bit 23through bit 16 for byte 2, and finally bit 127 through bit 120 for byte15. Thus, all available bits are used in the register. This storagearrangement increases the storage efficiency of the processor. As well,with sixteen data elements accessed, one operation can now be performedon sixteen data elements in parallel.

Generally, a data element is an individual piece of data that is storedin a single register or memory location with other data elements of thesame length. In packed data sequences relating to SSEx technology, thenumber of data elements stored in a XMM register is 128 bits divided bythe length in bits of an individual data element. Similarly, in packeddata sequences relating to MMX and SSE technology, the number of dataelements stored in an MMX register is 64 bits divided by the length inbits of an individual data element. Although the data types illustratedin FIG. 3A are 128 bit long, embodiments of the present invention canalso operate with 64 bit wide or other sized operands. The packed wordformat 320 of this example is 128 bits long and contains eight packedword data elements. Each packed word contains sixteen bits ofinformation. The packed doubleword format 330 of FIG. 3A is 128 bitslong and contains four packed doubleword data elements. Each packeddoubleword data element contains thirty two bits of information. Apacked quadword is 128 bits long and contains two packed quad-word dataelements.

FIG. 3B illustrates alternative in-register data storage formats. Eachpacked data can include more than one independent data element. Threepacked data formats are illustrated; packed half 341, packed single 342,and packed double 343. One embodiment of packed half 341, packed single342, and packed double 343 contain fixed-point data elements. For analternative embodiment one or more of packed half 341, packed single342, and packed double 343 may contain floating-point data elements. Onealternative embodiment of packed half 341 is one hundred twenty-eightbits long containing eight 16-bit data elements. One embodiment ofpacked single 342 is one hundred twenty-eight bits long and containsfour 32-bit data elements. One embodiment of packed double 343 is onehundred twenty-eight bits long and contains two 64-bit data elements. Itwill be appreciated that such packed data formats may be furtherextended to other register lengths, for example, to 96-bits, 160-bits,192-bits, 224-bits, 256-bits or more.

FIG. 3C illustrates various signed and unsigned packed data typerepresentations in multimedia registers according to one embodiment ofthe present invention. Unsigned packed byte representation 344illustrates the storage of an unsigned packed byte in a SIMD register.Information for each byte data element is stored in bit seven throughbit zero for byte zero, bit fifteen through bit eight for byte one, bittwenty-three through bit sixteen for byte two, and finally bit onehundred twenty-seven through bit one hundred twenty for byte fifteen.Thus, all available bits are used in the register: This storagearrangement can increase the storage efficiency of the processor. Aswell, with sixteen data elements accessed, one operation can now beperformed on sixteen data elements in a parallel fashion. Signed packedbyte representation 345 illustrates the storage of a signed packed byte.Note that the eighth bit of every byte data element is the signindicator. Unsigned packed word representation 346 illustrates how wordseven through word zero are stored in a SIMD register. Signed packedword representation 347 is similar to the unsigned packed wordin-register representation 346. Note that the sixteenth bit of each worddata element is the sign indicator. Unsigned packed doublewordrepresentation 348 shows how doubleword data elements are stored. Signedpacked doubleword representation 349 is similar to unsigned packeddoubleword in-register representation 348. Note that the necessary signbit is the thirty-second bit of each doubleword data element. In oneembodiment, one or more operands may be constant and therefore do notchange between instances of one or more instructions with which they areassociated.

FIG. 3D is a depiction of one embodiment of an operation encoding(opcode) format 360, having thirty-two or more bits, and register/memoryoperand addressing modes corresponding with a type of opcode formatdescribed in the “IA-32 Intel Architecture Software Developer's ManualVolume 2: Instruction Set Reference,” which is available from IntelCorporation, Santa Clara, Calif. on the world-wide-web (www) atintel.com/design/litcentr. In one embodiment, a string comparisonoperation may be encoded by one or more of fields 361 and 362. Up to twooperand locations per instruction may be identified, including up to twosource operand identifiers 364 and 365. For one embodiment of the stringcomparison instruction, destination operand identifier 366 is the sameas source operand identifier 364, whereas in other embodiments they aredifferent. For an alternative embodiment, destination operand identifier366 is the same as source operand identifier 365, whereas in otherembodiments they are different. In one embodiment of a string comparisoninstruction, one of the source operands identified by source operandidentifiers 364 and 365 is overwritten by the results of the stringcomparison operations, whereas in other embodiments identifier 364corresponds to a source register element and identifier 365 correspondsto a destination register element. For one embodiment of the stringcomparison instruction, operand identifiers 364 and 365 may be used toidentify 32-bit or 64-bit source and destination operands.

FIG. 3E is a depiction of another alternative operation encoding(opcode) format 370, having forty or more bits. Opcode format 370corresponds with opcode format 360 and comprises an optional prefix byte378. The type of string comparison operation may be encoded by one ormore of fields 378, 371, and 372. Up to two operand locations perinstruction may be identified by source operand identifiers 374 and 375and by prefix byte 378. For one embodiment of the string comparisoninstruction, prefix byte 378 may be used to identify 32-bit, 64-bit, or128-bit source and destination operands. For one embodiment of thestring comparison instruction, destination operand identifier 376 is thesame as source operand identifier 374, whereas in other embodiments theyare different. For an alternative embodiment, destination operandidentifier 376 is the same as source operand identifier 375, whereas inother embodiments they are different. In one embodiment, the stringcomparison operations compare each element of one of the operandsidentified by operand identifiers 374 and 375 to each element of anotheroperand identified by the operand identifiers 374 and 375 is overwrittenby the results of the string comparison operations, whereas in otherembodiments the string comparison of the operands identified byidentifiers 374 and 375 are written to another data element in anotherregister. Opcode formats 360 and 370 allow register to register, memoryto register, register by memory, register by register, register byimmediate, register to memory addressing specified in part by MOD fields363 and 373 and by optional scale-index-base and displacement bytes.

Turning next to FIG. 3F, in some alternative embodiments, 64 bit singleinstruction multiple data (SIMD) arithmetic operations may be performedthrough a coprocessor data processing (CDP) instruction. Operationencoding (opcode) format 380 depicts one such CDP instruction having CDPopcode fields 382 and 389. The type of CDP instruction, for alternativeembodiments of string comparison operations, may be encoded by one ormore of fields 383, 384, 387, and 388. Up to three operand locations perinstruction may be identified, including up to two source operandidentifiers 385 and 390 and one destination operand identifier 386. Oneembodiment of the coprocessor can operate on 8, 16, 32, and 64 bitvalues. For one embodiment, the string comparison operation is performedon integer data elements. In some embodiments, a string comparisoninstruction may be executed conditionally, using condition field 381.For some string comparison instructions source data sizes may be encodedby field 383. In some embodiments of string comparison instruction, Zero(Z), negative (N), carry (C), and overflow (V) detection can be done onSIMD fields. For some instructions, the type of saturation may beencoded by field 384.

In one embodiment, fields, or “flags”, may be used to indicate when aresult of a string comparison operation is non-zero. In someembodiments, other fields may be used, such flags to indicate when asource element is invalid, as well as flags to indicate a least or mostsignificant bit of a result of the string comparison operation.

FIG. 4 is a block diagram of one embodiment of logic to perform a stringcomparison operation on packed data operands in accordance with thepresent invention. Embodiments of the present invention can beimplemented to function with various types of operands such as thosedescribed above. For one implementation, string comparison operations inaccordance to the present invention are implemented as a set ofinstructions to operate on specific data types. For instance, a packedstring comparison instruction is provided to perform a comparison of32-bit data types, including integer and floating point. Similarly, apacked string comparison instruction is provided to perform a comparisonof 64-bit data types, including integer and floating point. Thefollowing discussions and examples below are to illustrate the operationof a comparison instruction to compare data elements, regardless of whatthe elements represent. For simplicity, some examples will illustratethe operation of one or more string comparison instructions, wherein thedata elements represent text words.

In one embodiment, a string comparison instruction compares each elementof a first data operand DATA A 410 with each element of a second dataoperand DATA B 420, and the result of each comparison stored in aRESULTANT 440 register. For the following discussions, DATA A, DATA B,and RESULTANT are generally referred to as registers, but not restrictedas such, and also include registers, register files, and memorylocations. In one embodiment, a text string compare instruction (e.g.,“PCMPxSTRy”) is decoded into one micro-operation. In an alternativeembodiment, each instruction may be decoded into a various number ofmicro-ops to perform the text string compare operation on the dataoperands. For this example, the operands 410, 420, are 128 bit widepieces of information stored in a source register/memory having wordwide data elements. In one embodiment, the operands 410, 420, are heldin 128 bit long SIMD registers, such as 128 bit SSEx XMM registers. Forone embodiment, the RESULTANT 440 is also a XMM data register. In otherembodiments, RESULTANT 440 may be a different type of register, such asan extended register (e.g., “EAX”), or a memory location. Depending onthe particular implementation, the operands and registers can be otherlengths such as 32, 64, and 256 bits, and have byte, doubleword, orquadword sized data elements. Although the data elements of this exampleare word size, the same concept can be extended to byte and doublewordsized elements. In one embodiment, where the data operands are 64 bitwide, MMX registers are used in place of the XMM registers.

In one embodiment, the first operand 410 is comprised of a set of eightdata elements: A7, A6, A5, A4, A3, A2, A1, and A0. Each comparisonbetween elements of the first and second operands may correspond to adata element position in the resultant 440. In one embodiment, thesecond operand 420 is comprised of another set of eight data segments:B7, B6, B5, B4, B3, B2, B1, and B0. The data segments here are of equallength and each comprise of a single word (16 bits) of data. However,data elements and data element positions can possess other granularitiesother than words. If each data element was a byte (8 bits), doubleword(32 bits), or a quadword (64 bits), the 128 bit operands would havesixteen byte wide, four doubleword wide, or two quadword wide dataelements, respectively. Embodiments of the present invention are notrestricted to particular length data operands or data segments, and canbe sized appropriately for each implementation.

The operands 410, 420, can reside either in a register or a memorylocation or a register file or a mix. The data operands 410, 420, aresent to the string comparison logic 430 of an execution unit in theprocessor along with a text string compare instruction. By the time theinstruction reaches the execution unit, the instruction may have beendecoded earlier in the processor pipeline, in one embodiment. Thus thestring comparison instruction can be in the form of a micro operation(uop) or some other decoded format. For one embodiment, the two dataoperands 410, 420, are received at string comparison logic 430. In oneembodiment, the text-string comparison logic generates an indication ofwhether elements of two data operands are equal. In one embodiment, onlyvalid elements of each operand are compared, which may be indicated byanother register or memory location for each element in each operand. Inone embodiment, each element of operand 410 is compared with eachelement of operand 420, which may generate a number of comparisonresults equal to the number of elements of operand 410 multiplied by thenumber elements of operand 420. In the case of each operand 410 and 420being 32 bit values, for example, the resultant register 440 will storeup to 4×4 result indicators of the text comparison operation performedby string comparison logic 430. In one embodiment, the data elementsfrom the first and second operands are single precision (e.g., 32 bit),whereas in other embodiments, the data elements from the first andsecond operands are double precision (e.g., 64 bit). Still, in otherembodiments, the first and second operands may include integer elementsof any size, including 8, 16, and 32 bits.

For one embodiment, the data elements for all of the data positions areprocessed in parallel. In another embodiment, a certain portion of thedata element positions can be processed together at a time. In oneembodiment, the resultant 440 is comprised of multiple results of thecomparisons made between each of the data elements stored in operands410 and 420. Specifically, in one embodiment the resultant may store anumber of comparison results equal to the square of the number of dataelements in one of the operands 410 or 420.

In one embodiment, the resultant may store comparison results for onlycomparisons made between valid data elements of the operands 410 and420. In one embodiment, the data elements of each operand may beexplicitly or implicitly indicated to be valid. For example, in oneembodiment each operand data element corresponds to a validityindicator, such as a valid bit, stored within another storage area, suchas a valid register. In one embodiment, validity bits for each elementof both operands may be stored in the same valid register, whereas inother embodiments, validity bits for one operand may be stored in afirst valid register and the validity bits for the other operand may bestored in a second valid register. Before the operand data elements arecompared, or in conjunction, a determination may be made as to whetherboth data elements are valid (for example by checking the correspondingvalid bits), such that comparisons are only made between valid dataelements.

In one embodiment, valid data elements in each operand may be implicitlyindicated by the use of null or “zero” fields stored within one or bothof the operands. For example, in one embodiment a null byte (or othersize) may be stored in an element to indicate that all more significantdata elements than the null byte are invalid, whereas all lesssignificant data elements than the null byte are valid and thereforeshould be compared to the corresponding valid data elements of the otheroperand. Furthermore, in one embodiment, valid data elements of oneoperand may be explicitly indicated (as described earlier), whereas thevalid data elements of the other operand may be implicitly indicatedusing null fields. In one embodiment, valid data elements are indicatedby a count corresponding to the number of valid data elements orsub-elements within one or more source operands.

Regardless of the method in which valid data elements of each operandare indicated, at least one embodiment only compares the data elementsof each operand that are indicated to be valid. Comparing only validdata elements may be performed in a number of ways in variousembodiments. For the purpose of providing a thorough and understandabledescription, the method by which only valid data elements are comparedbetween two text string operands may be best conceptualized by thefollowing. However, the following description is merely one example ofhow best to conceptualize or implement comparing only valid dataelements of text string operands. In other embodiments, otherconceptualizations or methods may be used to illustrate how valid dataelements are compared.

Regardless of whether the number of valid data elements in the operandsis explicitly indicated (e.g., via valid bits in a validity register orby a count of the number of valid bytes/words starting from the leastsignificant) or implicitly indicated (e.g., via null characters withinthe operands themselves), in one embodiment, only the valid dataelements of each operand are compared with each other. In oneembodiment, an aggregation of the validity indicators and the dataelements to be compared may be conceptualized in FIG. 5.

Referring to FIG. 5, in one embodiment, the arrays 501 and 505 containentries which indicate whether each of the elements of a first operandand a second operand, respectively, are valid. For example, in the aboveillustration, the array 501 array may contain a “1” in each arrayelement for which a first operand contains a corresponding valid dataelement. Similarly, array 505 may contain a “1” in each array elementfor which a second operand contains a corresponding valid data element.In one embodiment, the arrays 501 and 505 may contain ones starting inarray element zero for each valid element present in each of tworespective operands. For example, if a first operand contains four validelements, array 501 may contain ones only in the first four arrayelements and all other array elements of array 501 may be zeros, in oneembodiment.

In one embodiment, the arrays 501 and 505 are each 16 elements in sizeto represent 16 data elements of two 128 bit operands, each 8 bits (1byte) in size. In other embodiments, in which the data elements of theoperands are 16 bit (1 word) in size, arrays 501 and 505 may containonly 8 elements. In other embodiments, arrays 501 and 505 may be largeror smaller depending on the size of the operands to which theycorrespond.

In one embodiment, each data element of a first operand is compared toeach data element of a second operand, the result of which may berepresented by an i×j array 510. For example, a first data element of afirst operand, representing a text string, for example, may be comparedto each data element in another operand, representing another textstring, and a “1” stored in each array element within the first row ofthe array 510 corresponding to a match between the first data element ofthe first operand and each of the data elements of the second operand.This may be repeated for each data element in the first operand untilthe array 510 is completed.

In one embodiment, a second array 515 of i×j entries may be generated tostore indications of whether only valid operand data elements are equal.For example, in one embodiment, an entry of the top row 511 of array 510may be logically AND'ed with the corresponding valid array element 506and valid array element 502, and the result placed in the correspondingelement 516 of array 515. The AND operation may be completed betweeneach element of array 510 and the corresponding elements in valid arrays501 and 505, and the result placed in the corresponding element of array520.

In one embodiment, the result array 520 may indicate the presence ofdata elements in one operand which have relationships to one or moredata elements in the other operand. For example, result array 520 maystore bits to indicate whether there are any data elements which arewithin any of a set of ranges defined by data elements in the otheroperand, by AND'ing pairs of elements from array 515 and OR'ing all ofthe results from the AND'ing.

FIG. 5 also illustrates a result array 520 to store various indicatorspertaining to the comparison between data elements of at least twopacked operands. For example, result array 520 may store bits toindicate whether there are any equal data elements between the twooperands, by OR'ing the corresponding elements of the array 515. If anyof the array elements of array 515 contains a “1”, for example,indicating that a match exists between valid data elements of theoperands, then this may be reflected in result array 520, whose elementsmay also be OR'ed to determine if any valid data elements of theoperands are equal.

In one embodiment, a contiguous string of valid matches between the dataelements of two operands is detected within the result array 520 bydetecting adjacent “1” values within the array. In one embodiment, thismay be accomplished by AND'ing at two contiguous result array elementsat a time and AND'ing the result of one AND operation with the nextresult entry until a “0” is detected. In other embodiments, other logicmay be used to detect a range of valid matches of data elements withintwo packed operands.

In one embodiment, the result array 520 may indicate whether each dataelement of both operands match by returning a “1”, for example, in thecorresponding result array entry. In order to determine whether all ofthe entries are equal, an XOR operation may be performed on the resultarray entries. In other embodiments, other logic may be used todetermine whether each of valid data element of two operands are equal.

In one embodiment, the presence of a string of data elements somewherewithin another string of data elements may be detected by comparing atest string with equal sized portions of the other string and indicatinga match between the test string and the portion of the other stringwithin the result array. For example, in one embodiment, a test stringof three characters corresponding to three data elements in a firstoperand are compared with a first set of three data elements of a secondstring. If a match is detected, the match may be reflected in the resultarray by storing one or more “1” values in one or more of the groups ofthree result entries corresponding to a match. The test string may thenbe compared against the next three data elements of the other operand,or it may compare two of the previous operand data elements and a newthird data element with the test string, such that the test string‘slides’ along the other operand as it compares.

In one embodiment, the entries of the result array may be inverted, ornegated, depending upon the application. In other embodiments, only someof the result entries may be negated, such as only the ones that areindicated to correspond to valid matches between data elements of twooperands. In other embodiments, other operations may be performed on theresult entries of result array 520. For example, in some embodiments,the result array 520 may be represented as a mask value, whereas inother embodiments, the result array may be represented with an indexvalue, which may be stored into a storage location, such as a register.In one embodiment, an index may be represented by a group ofmost-significant bits of the result array, whereas in other embodimentsthe index may be represented by a group of least-significant bits of thearray. In one embodiment, the index may be represented by an offsetvalue to the least or most significant bit that is set. In oneembodiment, the mask may be zero extended, whereas in other embodiments,it may be a byte/word mask, or some other granularity.

In various embodiments, each variance described above in comparing eachelement of two or more SIMD operands may be performed as separateindividual instructions. In other embodiments, the variances describedabove may be performed by altering attributes of a single instruction,such as immediate fields associated with an instruction. FIG. 6illustrates various operations performed by one or more instructions tocompare each data element of two or more SIMD operands. In oneembodiment, the operands compared by the operations in FIG. 6 eachrepresent a text string. In other embodiments, the operands mayrepresent some other information or data.

Referring to FIG. 6, each element of a first SIMD operand 601 and asecond SIMD operand 605 may be compared to each other at operation 610.In one embodiment, one operand may be stored in a register, such as anXMM register, whereas the other operand may be stored in another XMMregister or in memory. In one embodiment, the type of comparison may becontrolled by an immediate field corresponding to an instructionperforming the operations illustrated in FIG. 6. For example, in oneembodiment, two bits of an immediate-field (e.g., IMM8[1:0]) may be usedto indicate whether the data elements to be compared are signed bytes,signed words, unsigned bytes, or unsigned words. In one embodiment, theresult of the comparison may generate an i×j array (e.g., BoolRes[i,j])or some portion of an i×j array.

In parallel, the end of each string represented by operands 601 and 605is found and the validity of each element of operand 601 and 605 may bedetermined at operation 613. In one embodiment, the validity of eachelement of operands 601 and 605 is indicated explicitly by setting acorresponding bit or bits within a register or memory location. In oneembodiment, the bit or bits may correspond to the number of consecutivevalid data elements (e.g., bytes) starting from the least significantbit position of the operand 601 and 605. For example, a register, suchas an EAX or RAX register, may be used to store bits indicating thevalidity of each data element of the first operand, depending on thesize of the operand. Similarly, a register, such as an EDX or RDX, maybe used to store bits indicating the validity of each data element ofthe second operand, depending on the size of the operand. In anotherembodiment, the validity of each element of operands 601 and 605 may beimplicitly indicated through means already discussed in this disclosure.

In one embodiment, the comparison and validity information may becombined by an aggregation function at operation 615 to produce someresult of comparing the elements of the two operands. In one embodiment,the aggregation function is determined by an immediate field associatedwith an instruction to perform the comparison of the elements of the twooperands. For example, in one embodiment, the immediate field mayindicate whether the comparison is to indicate whether any of the dataelements of the two operands are equal, whether any ranges (continuousor non-continuous) of data elements in the two operands are equal,whether each data element of the two operands are equal, or whether theoperands share an equal ordering of at least some data elements.

The result of the aggregation function (stored in IntRes1 array, forexample) may be negated, in one embodiment, at operation 620. In oneembodiment, bits of an immediate field (e.g., IMM8[6:5]) may control thetype of negating function to be performed on the aggregation functionresult. For example, immediate fields may indicate that the aggregationresults are not to be negated at all, that all results of theaggregation function are to be negated, or that only aggregation resultscorresponding to valid elements of the operands are to be negated. Inone embodiment, the result of the negating operation may be stored intoan array (e.g., IntRes2 array).

The result array generated by the negating operation may be convertedinto an index or a mask value, in one embodiment at operations 625 and630, respectively. If the negating operation result is converted into anindex, bits of an immediate field (e.g., IMM8[6]) may control whetherthe most significant bit(s) or the least significant bit(s) of theresult of the comparison is/are encoded into an index, the result ofwhich may be stored into a register (e.g., ECX or RCX). If the result ofthe negating operation is to be represented with a mask value in oneembodiment, bits of an immediate field (e.g., IMM8[6]) may be used tocontrol whether the mask is to be zero-extended or expanded to a byte(or word) mask.

Thus, techniques for performing a string compare operation aredisclosed. While certain exemplary embodiments have been described andshown in the accompanying drawings, it is to be understood that suchembodiments are merely illustrative of and not restrictive on the broadinvention, and that this invention not be limited to the specificconstructions and arrangements shown and described, since various othermodifications may occur to those ordinarily skilled in the art uponstudying this disclosure. In an area of technology such as this, wheregrowth is fast and further advancements are not easily foreseen, thedisclosed embodiments may be readily modifiable in arrangement anddetail as facilitated by enabling technological advancements withoutdeparting from the principles of the present disclosure or the scope ofthe accompanying claims.

What is claimed is:
 1. A processor comprising: a first logic to fetch acompare instruction; a decoder logic to decode the compare instruction;a plurality of 64-bit single-instruction multiple data (SIMD) integerdata registers, including: a first and second 64-bit SIMD integer dataregister to store a first and second 64-bit SIMD integer operand,respectively, each of the first and second 64-bit SIMD integer operandsto include a plurality of integer data elements; and a 64-bit SIMDdestination register, into which at least one result of performing thecompare instruction is to be stored, wherein the first and second 64-bitSIMD integer data registers and the 64-bit SIMD destination register areto be identified by a first and second SIMD operand field and a SIMDdestination field, respectively, of the compare instruction, and whereinthe compare instruction includes a field to indicate one of a pluralityof data element sizes for the integer data elements of the first andsecond 64-bit SIMD integer operands, including an 8-bit data elementsize, a 16-bit data element size, and a 32-bit data element size; and aplurality of execution units, wherein an execution unit of the pluralityof execution units is to execute the compare instruction, wherein thecompare instruction is to cause the processor to: compare integer dataelements of the first 64-bit SIMD integer operand with integer dataelements of the second 64-bit SIMD integer operand, wherein the integerdata elements of the first 64-bit SIMD integer operand to be comparedwith the integer data elements of the second 64-bit SIMD integer operandare to be in same data element positions, and store a plurality ofindicators of whether the compared integer data elements of the first64-bit SIMD integer operand and the integer data elements of the second64-bit SIMD integer operand are equal, wherein the plurality ofindicators are expanded data elements, each of a first multi-bit size.2. The processor of claim 1, wherein the processor is a RISC processor.3. The processor of claim 1, wherein the field to indicate said one ofthe plurality of data element sizes is a 2-bit field.
 4. The processorof claim 1, wherein the compare instruction is a first compareinstruction, the first logic to fetch a second compare instruction tocompare a first plurality of packed single precision floating point(SPFP) data elements with a second plurality of packed SPFP dataelements, wherein at least one execution unit of the plurality ofexecution units is to execute the second compare instruction, whereinthe second compare instruction is to cause the processor to: determinewhether each of the packed SPFP data elements of the first and secondplurality of packed SPFP data elements is valid, compare only valid SPFPdata elements of the first plurality of packed SPFP data elements withonly valid SPFP data elements of the second plurality of packed SPFPdata elements, and store a plurality of indicators of whether thecompared valid SPFP data elements of the first plurality of packed SPFPdata elements and the valid SPFP data elements of the second pluralityof packed SPFP data elements are equal.
 5. A processor comprising: adecoder to decode a compare instruction; a plurality of 64-bitsingle-instruction multiple data (SIMD) integer data registers,including: a first 64-bit SIMD integer data register to store a first64-bit SIMD integer operand that is to include a plurality of integerdata elements; a second 64-bit SIMD integer data register to store asecond 64-bit SIMD integer operand that is to include a plurality ofinteger data elements; and a 64-bit SIMD destination register, intowhich at least one result of performing the compare instruction is to bestored, wherein the first 64-bit SIMD integer data register is to beidentified by a first SIMD operand field of the compare instruction, thesecond 64-bit SIMD integer data register is to be identified by a secondSIMD operand field of the compare instruction, and the 64-bit SIMDdestination register is to be identified by a SIMD destination field ofthe compare instruction, and wherein the compare instruction includes afield to indicate one of a plurality of data element sizes for theinteger data elements of the first 64-bit SIMD integer operand, theplurality of data element sizes to include an 8-bit data element size, a16-bit data element size, and a 32-bit data element size; and aplurality of execution units, wherein an execution unit of the pluralityof execution units is to execute the compare instruction, wherein thecompare instruction is to cause the processor to: compare integer dataelements of the first 64-bit SIMD integer operand with integer dataelements of the second 64-bit SIMD integer operand, wherein the integerdata elements of the first 64-bit SIMD integer operand to be comparedwith the integer data elements of the second 64-bit SIMD integer operandare to be in same data element positions, and store a plurality ofindicators of whether the compared integer data elements of the first64-bit SIMD integer operand and the integer data elements of the second64-bit SIMD integer operand are equal, wherein the plurality ofindicators are expanded data elements, each of a first multi-bit size.6. The processor of claim 5, wherein the processor is a RISC processor.7. The processor of claim 5, wherein the field to indicate said one ofthe plurality of data element sizes is a 2-bit field.
 8. The processorof claim 7, wherein the compare instruction is a first compareinstruction, the first logic to fetch a second compare instruction tocompare a first plurality of packed single precision floating point(SPFP) data elements with a second plurality of packed SPFP dataelements, wherein at least one execution unit of the plurality ofexecution units is to execute the second compare instruction, whereinthe second compare instruction is to cause the processor to: determinewhether each of the packed SPFP data elements of the first and secondplurality of packed SPFP data elements is valid, compare only valid SPFPdata elements of the first plurality of packed SPFP data elements withonly valid SPFP data elements of the second plurality of packed SPFPdata elements, and store a plurality of indicators of whether thecompared valid SPFP data elements of the first plurality of packed SPFPdata elements and the valid SPFP data elements of the second pluralityof packed SPFP data elements are equal.
 9. A processor comprising: adecoder to decode a compare instruction; a plurality of 64-bitsingle-instruction multiple data (SIMD) integer data registers,including: a first 64-bit SIMD integer data register to store a first64-bit SIMD integer operand that is to include a plurality of integerdata elements; a second 64-bit SIMD integer data register to store asecond 64-bit SIMD integer operand that is to include a plurality ofinteger data elements; and a 64-bit SIMD destination register, intowhich at least one result of performing the compare instruction is to bestored, wherein the first 64-bit SIMD integer data register is to beidentified by a first SIMD operand field of the compare instruction, thesecond 64-bit SIMD integer data register is to be identified by a secondSIMD operand field of the compare instruction, and the 64-bit SIMDdestination register is to be identified by a SIMD destination field ofthe compare instruction, and wherein the compare instruction includes a2-bit field to indicate one of a plurality of data element sizes for theinteger data elements of the first 64-bit SIMD integer operand, theplurality of data element sizes to include an 8-bit data element size, a16-bit data element size, and a 32-bit data element size; and aplurality of execution units, wherein an execution unit of the pluralityof execution units is to execute the compare instruction, wherein thecompare instruction is to cause the processor, which is a RISCprocessor, to: compare integer data elements of the first 64-bit SIMDinteger operand with integer data elements of the second 64-bit SIMDinteger operand, wherein the integer data elements of the first 64-bitSIMD integer operand to be compared with the integer data elements ofthe second 64-bit SIMD integer operand are to be in same data elementpositions, and store a plurality of indicators of whether the comparedinteger data elements of the first 64-bit SIMD integer operand and theinteger data elements of the second 64-bit SIMD integer operand areequal, wherein the plurality of indicators are expanded data elements,each of a first multi-bit size.